<template>
  <div>
    <div class="rankingnav">
      <div class="rankingnav-box">
        <div class="rankingnav-blue" :style="{ top: tops + 'rem' }"></div>
        <div
          class="rankingnav-item"
          v-for="(item, index) in rankingItem"
          :key="index"
          @mouseenter="changtop(index)"
          @mouseleave="changleave()"
          @click="changIndex(index)"
        >
          <div class="ranking-chnag">
            <img :src="item.img" alt="" />
          </div>
          <div :class="{ rankingactive: indexs === index }">
            {{ item.name }}
          </div>
        </div>
      </div>
    </div>

    <div class="rankinglist" v-loading="loading">
      <div
        class="rankinglist-item"
        v-for="(item, index) in rankingLis"
        :key="index"
      >
        <div class="ranking-img">
          <div v-if="index == 0">
            <img src="../../assets/img/one.svg" alt="" />
          </div>
          <div v-if="index == 1">
            <img src="../../assets/img/tow.svg" alt="" />
          </div>
          <div v-if="index == 2">
            <img src="../../assets/img/disan.svg" alt="" />
          </div>
          <div v-if="index != 0 && index != 1 && index != 2">
            <div class="ranking-bottom">
              {{ index + 1 }}
            </div>
          </div>
        </div>

        <div class="ranking-foodimg">
          <div class="imgChuLi">
            <a :href="footHref + rankingLis[index].fid"
              ><img :src="rankingLis[index].fimg" alt=""
            /></a>
          </div>
        </div>

        <div class="ranking-jies">
          <div class="jiesName">
            <a :href="footHref + rankingLis[index].fid">{{
              rankingLis[index].fname
            }}</a>
          </div>
          <div class="jiesLie">
            <a :href="footHref + rankingLis[index].fid"
              >美食类别 : {{ rankingLis[index].ftName }}</a
            >
          </div>
          <div class="jiesNei">
            <a :href="footHref + rankingLis[index].fid">{{
              rankingLis[index].fcontent
            }}</a>
          </div>
          <div class="jiesCount">
            <a :href="footHref + rankingLis[index].fid"
              >访问数 : {{ rankingLis[index].fvisits }}
            </a>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { request } from "../../network/request";

export default {
  name: "RankingDesserts",
  data() {
    return {
      rankingItem: [
        {
          img: "http://juntower.top/redu.svg",
          url: "/rankingpage",
          name: "热度榜",
        },
        {
          img: "http://juntower.top/miantiao.svg",
          url: "/rankingchinese",
          name: "中式榜",
        },
        {
          img: "http://juntower.top/kaoya.svg",
          url: "/rankingtradition",
          name: "传统榜",
        },
        {
          img: "http://juntower.top/hanbao.svg",
          url: "/rankingamerican",
          name: "美式榜",
        },
        {
          img: "http://juntower.top/tianping.svg",
          url: "/rankingdesserts",
          name: "甜品榜",
        },
      ],
      indexs: 4,
      rankingLis: "",
      footHref: "/showfood?fid=",
      loading: true,
      tops: 2.19,
      stops: 2.19,
      changetop: 0,
      navFixed: false,
      nones: false,
    };
  },
  created() {
    request({
      url: "/foot/queryRankingFootByFtId",
      method: "GET",
      params: {
        ftId: this.indexs,
      },
    })
      .then((res) => {
        this.rankingLis = res.data.data;
        this.loading = false;
        this.$emit("childByFeedList", this.rankingLis);
      })
      .catch((err) => {
        console.log(err);
      });
  },
  methods: {
    changtop(index) {
      if (index == 0) {
        this.tops = 0.07;
      }
      if (index == 1) {
        this.tops = 0.07 + 0.55;
      }
      if (index == 2) {
        this.tops = 0.07 + 0.52 * 2;
      }
      if (index == 3) {
        this.tops = 0.07 + 0.52 * 3;
      }
      if (index == 4) {
        this.tops = 0.07 + 0.53 * 4;
      }
    },

    changleave() {
      this.tops = this.stops;
    },

    changIndex(index) {
      this.$router.push(this.rankingItem[index].url);
      location.reload();
    },
  },
};
</script>

<style>
</style>